$(function(){
    obj.init();
});

var obj = new JsFun();
function JsFun(){
    'use strict';
    return {
        dataGrid: null,
        schoolId:null,
        save:null,
        init: function () {
            this.save = window.top.xhTop.getModalConfirmDom();
            var form = new xhForm($('#xh_form'));
            form.parse().bindRequired($('#submit'));
            this.listener();
        },
        listener: function () {
            var $this = this;
            $('#cancel').click(function () {
                window.top.xhTop.closeModal();
            });

            $this.save.click(function () {
                $this.funObj().save();
            });
        },
        funObj: function(){
            var $this = this;
            return {
                save: function () {
                    var keys = [];
                    var configures = $("input[name='configure']:checked");
                    for (var i=0; i<configures.length; i++){
                        if(configures[i].checked){
                            keys.push(configures[i].value);
                        }
                    }
                    $.ajax({
                        url:baseUrl+'school/userConfigureSet',
                        data: {ids: ids, keys: keys.join()},
                        type:'POST',
                        success:function (data) {
                            window.top.xhTop.showSuccess(data.msg);
                            window.top.xhTop.closeModal();
                        },
                        error:function (data) {
                            window.top.swal(
                                data['responseText'],
                                '',
                                'error'
                            );
                        }
                    });
                }
            }
        }
    }
}

